<template>
  <div class="login-container">
    <div style="
        margin: 20px 0;
        text-align: center;
        font-size: 24px;
        padding-left: 30px;
        color: #fff;
      ">
      <h1>听个响音乐管理系统</h1>
    </div>

    <div class="form-box">
      <el-form :model="loginForm" :rules="rules" ref="loginForm">
        <h1 style="color: #fff; margin-top: -60px; margin-bottom: 10px">
          登录
        </h1>
        <el-form-item label="用户名" prop="username" size="small" class="item">
          <el-input prefix-icon="el-icon-user-solid" placeholder="用户名" style="margin: 10px 0"
            v-model="loginForm.username" autocomplete="off" clearable>
          </el-input>
        </el-form-item>
        <el-form-item label="密码" prop="password" size="small" class="item">
          <el-input prefix-icon="el-icon-lock" type="password" placeholder="密码" style="margin: 10px 0"
            v-model="loginForm.password" autocomplete="off" clearable show-password>
          </el-input>
        </el-form-item>
        <el-form-item style="padding: 10px 0" size="small">
          <el-button type="primary" @click="login('loginForm')">登录</el-button>
          <el-button @click="regist('loginForm')">注册</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      //提交的表单数据
      loginForm: {
        username: "",
        password: "",
      },
      //表单校验规则
      rules: {
        username: [{ message: "用户名不能为空" }],
        password: [{ message: "密码不能为空" }],
      },
    };
  },
  methods: {
    //登录
    login(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          // console.log(this.loginForm.username)
          // console.log(this.loginForm.password)
          //跳转到首页
          this.$router.push('/home')
          this.$notify({
            title: '登录成功',
            message: '你已登录成功！',
            type: 'success'
        });
        } else {
          // console.log('error submit!!');
          return false;
        }
      });
    },
    regist() { },
  },
};
</script>

<style>
.login-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  /* background-image: url('../assets/bg.jpg');
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: 100% auto; */

  /* background-image: linear-gradient(to bottom right, #fc466b, #3f5efb); */
  background-image: url('../assets/bg.jpg');
  background-position: center center;
  background-repeat: no-repeat;
  background-size: 100% auto;
  overflow: hidden;
}

.el-form-item__label .item {
  color: #fff;
}

.el-form-item {
  width: 300px;
}

.el-form {
  margin: 100px 0;
}

.form-box {
  display: flex;
  justify-content: center;
  margin: 50px auto;
  background-color: #00000068;
  border-radius: 13px;
  text-align: center;
  width: 350px;
  height: 450px;
}
</style>